package class1;

import src.class1.Pet;

public class PetInstanceOf {
    public static void main(String[] args) {
        Pet[] a={
          new Pet("盖伊","方勇军"),
          new RobotPet("没事","小河"),
          new Pet("村长","翠花"),
        };
        for (int i = 0; i <a.length ; i++) {
            System.out.println("a["+i+"]");
            if (a[i] instanceof RobotPet)
                ((RobotPet)a[i]).work(0);
            else
                a[i].introduce();
        }
    }
}
